import useUserStore from '@/store/modules/user'
import { getRecentDays, getDayOfMonth } from '@/utils/ty.js'

/**
 * 角色默认查询条件
 * @param {Array} url 请求接口
 * @returns {Boolean}
 */
export function searchDefaultParams(url) {
	const userStore = useUserStore()
  const params = {}
	const role = userStore.roleKey
	// console.log(role)
	switch (url) {
		case'order' :
			if (role === 'sales_man') { // 销售
				params.startTime = `${getRecentDays(15)} 00:00:00`
			} else if (role === 'sales_area_manager') { // 区域主管
				params.startTime = `${getRecentDays(7)} 00:00:00`
			} else if (role === 'sales_provincial_manger') { // 省区经理
				params.startTime = `${getRecentDays(30)} 00:00:00`
			} else if (role === 'peisong-warehouse') {
				params.status = 1
			} else if (role === 'caigou_manager') {
				params.status = 1
				params.startTime = `${getRecentDays(1)} 00:00:00`
			} else if (role === 'purchaseManager') {
				params.status = 1
				params.startTime = `${getRecentDays(1)} 00:00:00`
			} else { // 其他
				params.startTime = `${getRecentDays(7)} 00:00:00`
			}
			break;
		case'supplierProductSaleSummary' :
			if (role === 'caigou_manager') {
				params.status = [1]
				params.startTime = `${getRecentDays(1)} 06:00:00`
				params.endTime = `${getRecentDays(0)} 06:00:00`
			} else if (role === 'purchaseManager') {
				params.status = [1]
				params.startTime = `${getRecentDays(1)} 06:00:00`
				params.endTime = `${getRecentDays(0)} 06:00:00`
			} else { // 其他
				params.status = [1, 2, 3, 4, 6]
				params.startTime = `${getDayOfMonth().startTime} 00:00:00`
				params.endTime = `${getDayOfMonth().endTime} 23:59:59`
			}
			break;
		default:
	}
	return params
}
